package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.entity.Result;
import com.itheima.service.InterventionService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/*
    健康干预表现层
 */
@RestController
@RequestMapping("/intervention")
public class InterventionController {


    //注入健康干预服务层接口
    @Reference
    private InterventionService interventionService;


    //添加健康建议
    @RequestMapping("/add")
    public Result add(Integer[] foodIds,Integer[] sportIds,Integer interventionId,String suggestion){
        try{
            //调用服务层接口
            interventionService.add(foodIds,sportIds,interventionId,suggestion);
            //添加成功,返回结果
            return new Result(true,MessageConstant.ADD_INTERVENTION_SUCCESS);
        }catch (Exception e){
            e.printStackTrace();
            //添加失败,返回错误信息
            return new Result(false, MessageConstant.QUERY_SPORTS_SUCCESS);
        }
    }
}
